import pytest,requests
from Page.Page import Page
from selenium import webdriver
from selenium.webdriver.ie.service import Service
from Utils.Utils import get_logger
logger=get_logger()


@pytest.fixture(scope='function')
def driver():
    logger.info('初始化驱动')
    #此处用的是edge浏览器启动
    edge_service=Service(r'D:\2--学习软件安装包\msedgedriver.exe')
    driver=webdriver.Edge(service=edge_service)

    driver.set_page_load_timeout(7)
    driver.implicitly_wait(10)

    #返回数据
    yield driver
    driver.quit()
    logger.info('关闭驱动')

@pytest.fixture(scope='function')
#登录接口提取userId和sessionId
def login_wd():
    url='http://10.59.9.18/movieApi/user/v2/login'
    body={'email':'1478997572@qq.com',
          'pwd':'eWLPHopE945d2ivttHaQTQ=='}
    res=requests.post(url=url,data=body)
    print(res.json())
    yield res.json()['result']['userId'],res.json()['result']['sessionId']

